<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/base}">
<head>
    <title>寄件 - 快递管理系统</title>
</head>
<body>
    <div layout:fragment="content">
        <h2 class="mb-4">寄件</h2>

        <!-- 消息提示区域 -->
        <div th:if="${message}" class="alert alert-success alert-dismissible fade show" role="alert">
            <i class="fas fa-check-circle me-2"></i>
            <span th:text="${message}"></span>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
        <div th:if="${error}" class="alert alert-danger alert-dismissible fade show" role="alert">
            <i class="fas fa-exclamation-circle me-2"></i>
            <span th:text="${error}"></span>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>

        <form th:action="@{/orders/send}" th:object="${expressOrder}" method="post">
            <div class="mb-3">
                <label for="senderName" class="form-label">寄件人姓名</label>
                <input type="text" class="form-control" id="senderName" th:field="*{senderName}" required>
            </div>
            <div class="mb-3">
                <label for="senderPhone" class="form-label">寄件人手机号</label>
                <input type="text" class="form-control" id="senderPhone" th:field="*{senderPhone}" required>
            </div>
            <div class="mb-3">
                <label for="senderAddress" class="form-label">寄件地址</label>
                <input type="text" class="form-control" id="senderAddress" th:field="*{senderAddress}" required>
            </div>
            <div class="mb-3">
                <label for="receiverName" class="form-label">收件人姓名</label>
                <input type="text" class="form-control" id="receiverName" th:field="*{receiverName}" required>
            </div>
            <div class="mb-3">
                <label for="receiverPhone" class="form-label">收件人手机号</label>
                <input type="text" class="form-control" id="receiverPhone" th:field="*{receiverPhone}" required>
            </div>
            <div class="mb-3">
                <label for="receiverId" class="form-label">选择系统内收件人（可选）</label>
                <select class="form-select" id="receiverId" th:field="*{receiverId}">
                    <option value="">请选择系统内收件人（可选）</option>
                    <option th:each="user : ${users}" th:value="${user.id}" th:text="${user.realName + ' (' + user.phoneNumber + ')'}"></option>
                </select>
                <div class="form-text text-muted">
                    <i class="fas fa-info-circle"></i> 如果不选择系统内收件人，收件人将无法在系统中查看此订单。
                </div>
            </div>
            <div class="mb-3">
                <label for="receiverAddress" class="form-label">收货地址</label>
                <input type="text" class="form-control" id="receiverAddress" th:field="*{receiverAddress}" required>
            </div>
            <div class="mb-3">
                <label for="packageType" class="form-label">包裹类型</label>
                <select class="form-select" id="packageType" th:field="*{packageType}" required>
                    <option value="">请选择包裹类型</option>
                    <option value="文件">文件</option>
                    <option value="包裹">包裹</option>
                    <option value="易碎品">易碎品</option>
                    <option value="其他">其他</option>
                </select>
            </div>
            <div class="mb-3">
                <label for="weight" class="form-label">包裹重量 (kg)</label>
                <input type="number" step="0.1" class="form-control" id="weight" th:field="*{weight}" required>
            </div>
            <button type="submit" class="btn btn-primary">提交寄件</button>
        </form>
    </div>
</body>
</html> 